package com.tool4j.entity.params;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.io.Serializable;

/**
 * @author Deng.Weiping
 * @since 2023/11/9 16:00
 */
@Data
public class PageParams<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private T params;

    @TableField(exist = false)
    @Min(value = 1, message = "当前页面不能小于1")
    private int current;

    @TableField(exist = false)
    @Min(value = 1, message = "每页条数最少1条")
    @Max(value = 1000, message = "每页条数最多1000条")
    private int pageSize;

    @TableField(exist = false)
    private int total;

    public Page getPage() {
        return new Page<>(this.current, this.pageSize);
    }
}
